package com.ywjt.pinkelephant.widget;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ywjt.pinkelephant.R;
import com.ywjt.pinkelephant.base.BaseBottomDialog;


public class SizeBottomDialog extends BaseBottomDialog {
    private TextView tvAll,tvRate9,tvRate3,tvRate1;
    private Context mContext;

    private ClickListenerInterface clickListenerInterface;

    public interface ClickListenerInterface {
        void callback(int mode);//1 全面屏， 2 9：16 ，3 3：4， 4 1：1
    }

    public SizeBottomDialog(Context mContext) {
        this.mContext=mContext;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.bottom_size_select;
    }

    @Override
    public void bindView(View v) {
        tvAll=v.findViewById(R.id.tvAll);
        tvRate9=v.findViewById(R.id.tvRate9);
        tvRate3=v.findViewById(R.id.tvRate3);
        tvRate1=v.findViewById(R.id.tvRate1);

        tvAll.setOnClickListener(new clickListener());
        tvRate9.setOnClickListener(new clickListener());
        tvRate3.setOnClickListener(new clickListener());
        tvRate1.setOnClickListener(new clickListener());
    }


    public void setClicklistener(ClickListenerInterface clickListener) {
        clickListenerInterface = clickListener;
    }

    private class clickListener implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.tvAll:
                    //全面屏
                    reSetStatus();
                    tvAll.setTextColor(mContext.getResources().getColor(R.color.white));
                    clickListenerInterface.callback(1);
                    break;
                case R.id.tvRate9:
                    //9：16
                    reSetStatus();
                    tvRate9.setTextColor(mContext.getResources().getColor(R.color.white));
                    clickListenerInterface.callback(2);
                    break;
                case R.id.tvRate3:
                    reSetStatus();
                    tvRate3.setTextColor(mContext.getResources().getColor(R.color.white));
                    clickListenerInterface.callback(3);
                    break;
                case R.id.tvRate1:
                    reSetStatus();
                    tvRate1.setTextColor(mContext.getResources().getColor(R.color.white));
                    clickListenerInterface.callback(4);
                    break;
                default:
                    break;
            }
        }
    }


    //重置数据
    public void reSetStatus(){
        tvAll.setTextColor(mContext.getResources().getColor(R.color.trans_white));
        tvRate9.setTextColor(mContext.getResources().getColor(R.color.trans_white));
        tvRate3.setTextColor(mContext.getResources().getColor(R.color.trans_white));
        tvRate1.setTextColor(mContext.getResources().getColor(R.color.trans_white));
    }
}
